package com.wxit.limit.stopwatch;

import org.springframework.util.StopWatch;

public class StopWatchTest {
    public static void main(String[] args) throws InterruptedException {

        long start = System.currentTimeMillis();
        Thread.sleep(100);
        long end = System.currentTimeMillis();
        System.out.println("任务执行的时间为:" + (end - start));

        System.out.println("-----------------------");
        StopWatch sw = new StopWatch();
        sw.start();

        Thread.sleep(1000);
        sw.stop();
        System.out.println(sw.getTotalTimeMillis());

        System.out.println("------------------");
        StopWatch stopWatch = new StopWatch();
        stopWatch.start("a");
        Thread.sleep(500);
        stopWatch.stop();

        stopWatch.start("b");
        Thread.sleep(300);
        stopWatch.stop();

        stopWatch.start("c");
        Thread.sleep(200);
        stopWatch.stop();

        System.out.println(stopWatch.prettyPrint());
    }
}
